package com.platform.api.bzproject.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.api.bzproject.dao.BzBaseInfoMapper;
import com.platform.api.bzproject.model.BzBaseInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author guoyunfei on 2021/8/12 14:07
 * @className BzBaseInfoService
 * @description TODO
 * @Version 1.0
 */
@Service
@Transactional(rollbackFor=Exception.class)
public class BzBaseInfoService extends ServiceImpl<BzBaseInfoMapper, BzBaseInfo> {


    //获取小程序基础配置信息
    public BzBaseInfo selectOne(String appid){

        QueryWrapper<BzBaseInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("appid",appid);
        BzBaseInfo info = this.getOne(queryWrapper);
        return info;
    }

    public BzBaseInfo getAppletInfo(String appid){

        BzBaseInfo info = getOne(new LambdaQueryWrapper<BzBaseInfo>()
                .eq(BzBaseInfo::getAppid, appid)
                .select(BzBaseInfo::getIsTools,BzBaseInfo::getShowAd,BzBaseInfo::getAppName,BzBaseInfo::getAdCount,
                        BzBaseInfo::getDownCount,BzBaseInfo::getPutongDown,BzBaseInfo::getCloseProfit)
                .last("limit 1"));
        return info;
    }

}
